﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fluent;
using Fluent.HtmlModel;

namespace Fluent.HtmlModel
{
    public class Navigator<TPage, TNavigatePage> : Link<TPage>
        where TPage : WebPageBase
        where TNavigatePage : WebPageBase
    {
        public Navigator(TPage page, Finder finder)
            : base(page, finder) { }

        public TNavigatePage Navigate()
        {
            this.Click();
            var navigatedPage = this.Page.Browser.GetPage<TNavigatePage>();

            return navigatedPage;
        }

        public TNavigatePage Navigate(Action<TNavigatePage> actionsInNavigatedPage)
        {
            this.Click();
            var navigatedPage = this.Page.Browser.GetPage<TNavigatePage>();
            actionsInNavigatedPage(navigatedPage);

            return navigatedPage;
        }
    }
}
